package com.kh.pajx.sop.dao.bal.impl;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.kh.pajx.sop.base.BaseDaoImpl;
import com.kh.pajx.sop.dao.bal.IBalCustMgrDriveDao;
import com.kh.pajx.sop.domain.bal.BalCustMgrDrive;

/**
 * 移动客户经理结算 数据库持久化操作实现类
 * @author:	azzcsimp
 * @Createdate:	2015年1月27日 下午4:53:28
 */
@Repository
@SuppressWarnings("unchecked")
public class BalCustMgrDriveDaoImpl extends BaseDaoImpl<BalCustMgrDrive> implements IBalCustMgrDriveDao {
	
	@Override
	public List<BalCustMgrDrive> findListByState(int state) throws Exception{
		return getSession().createQuery(//
				"FROM BalCustMgrDrive bal WHERE bal.billState=?") //
				.setParameter(0, state) //
				.list(); //
	}
	
	@Override
	public List<BalCustMgrDrive> findList(String billCode, int billState) throws Exception {
		return getSession().createQuery(//
				"FROM BalCustMgrDrive bal WHERE bal.billCode=? AND bal.billState=? ")
				.setParameter(0, billCode)
				.setParameter(1, billState)
				.list();
	}
	
	@Override
	public List<BalCustMgrDrive> findByBillCodeList(List<String> bumgrBills) throws Exception {
		return getSession().createQuery(//
				"FROM BalCustMgrDrive bal WHERE bal.billState=3 AND bal.billCode in (:billcodeList)") //
				.setParameterList("billcodeList", bumgrBills)//
				.list();
	}
	
	@Override
	public List<BalCustMgrDrive> findByBillCodeList(List<String> bumgrBills,String areaCode) throws Exception {
		return getSession().createQuery(//
				"SELECT bal FROM BalCustMgrDrive bal,HsSchoolInfo scl WHERE bal.sclId = scl.sclId AND scl.areaCode=? AND bal.billState=3 AND bal.billCode in (:billcodeList)") //
				.setParameter(0, areaCode)//
				.setParameterList("billcodeList", bumgrBills)//
				.list();
	}
	
	@Override
	public List<BalCustMgrDrive> findByBillCodeList(List<String> bumgrBills,String areaCode, String deptCode) throws Exception {
		return getSession().createQuery(//
				"FROM BalCustMgrDrive bal WHERE bal.saleDeptId=? AND bal.billState=3 AND bal.billCode in (:billcodeList)") //
				.setParameter(0, deptCode)
				.setParameterList("billcodeList", bumgrBills)//
				.list();
	}
}
